package com.iot.device.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iot.device.mapper.GasClientMapper;
import com.iot.device.domain.GasClient;
import com.iot.device.service.IGasClientService;

/**
 * 燃气监测设备Service业务层处理
 * 
 * @author iot
 * @date 2023-04-14
 */
@Service
public class GasClientServiceImpl implements IGasClientService 
{
    @Autowired
    private GasClientMapper gasClientMapper;

    /**
     * 查询燃气监测设备
     * 
     * @param id 燃气监测设备主键
     * @return 燃气监测设备
     */
    @Override
    public GasClient selectGasClientById(Long id)
    {
        return gasClientMapper.selectGasClientById(id);
    }

    /**
     * 查询燃气监测设备列表
     * 
     * @param gasClient 燃气监测设备
     * @return 燃气监测设备
     */
    @Override
    public List<GasClient> selectGasClientList(GasClient gasClient)
    {
        return gasClientMapper.selectGasClientList(gasClient);
    }

    /**
     * 新增燃气监测设备
     * 
     * @param gasClient 燃气监测设备
     * @return 结果
     */
    @Override
    public int insertGasClient(GasClient gasClient)
    {
        return gasClientMapper.insertGasClient(gasClient);
    }

    /**
     * 修改燃气监测设备
     * 
     * @param gasClient 燃气监测设备
     * @return 结果
     */
    @Override
    public int updateGasClient(GasClient gasClient)
    {
        return gasClientMapper.updateGasClient(gasClient);
    }

    /**
     * 批量删除燃气监测设备
     * 
     * @param ids 需要删除的燃气监测设备主键
     * @return 结果
     */
    @Override
    public int deleteGasClientByIds(Long[] ids)
    {
        return gasClientMapper.deleteGasClientByIds(ids);
    }

    /**
     * 删除燃气监测设备信息
     * 
     * @param id 燃气监测设备主键
     * @return 结果
     */
    @Override
    public int deleteGasClientById(Long id)
    {
        return gasClientMapper.deleteGasClientById(id);
    }

    @Override
    public GasClient selectGasClientByClientNo(String clientNo) {
        return gasClientMapper.selectGasClientByClientNo(clientNo);
    }

    @Override
    public void updateGasClientByClientNo(GasClient gasClient) {
        gasClientMapper.updateGasClientByClientNo(gasClient);
    }

    @Override
    public Set<String> selectGasClientNosByUserId(Long userId) {
        return gasClientMapper.selectGasClientNosByUserId(userId);
    }

    @Override
    public Map<String, Long> countGasClientsByUserId(Long userId) {
        return gasClientMapper.countGasClientsByUserId(userId);
    }

    @Override
    public List<GasClient> selectGasClientWithInfos(GasClient gasClient) {
        return gasClientMapper.selectGasClientWithInfos(gasClient);
    }

    @Override
    public Map<String, Long> selectGasClientStatistics(Long userId) {
        Map<String, Long> map = gasClientMapper.selectGasClientStatistics(userId);
        if(map == null){
            map = new HashMap<>();
            map.put("onlineCount", 0L);
            map.put("totalCount", 0L);
        }
        return map;
    }
}
